package com.hankol.community.bean

import android.annotation.SuppressLint
import android.text.TextUtils
import com.baselibrary.BuildConfig
import com.baselibrary.Constants
import com.baselibrary.base.BasicBean
import com.baselibrary.bean.LIVE_STATE_NO_START
import com.baselibrary.bean.SelectSendFriend4Bean
import com.baselibrary.bean.TimelineInfoData
import com.baselibrary.router.ActivityRouter
import com.hankol.community.api.CommunityConstant
import kotlinx.android.parcel.Parcelize


@SuppressLint("ParcelCreator")
@Parcelize
data class ShowShare2Bean(
        var id: Long = 0,
        var uid: Int = 0,//用户id
        var showType: Int = 0,
        var isFans: Int = 0,
        var name: String = "",
        var headUrl: String = "",
        var cover: String = "",
        var title: String = "",
        var content: String = "",
        var url: String = "",
        var pulpitId: Long = 0//讲坛id【讲坛课程页分享用】
) : BasicBean()


fun clientTimeline2SelectSendFriend2Bean(fromeBean: TimelineInfoData.ClientTimeline): SelectSendFriend4Bean {
    return SelectSendFriend4Bean().apply {
        fromeBean.let {
            id = it.id
            showType = it.showType
            cover = it.cover
            images = it.images
            title = if (TextUtils.isEmpty(it.title)) it.content else it.title
            content = it.content
            icon = it.user.icon
            name = it.user.name
            isFans = it.user.isFans
            route = it.route
        }
    }
}
fun clientTimeline2SelectSendFriend2Bean(fromeBean: FollowDynamicBean.DataBeanX.DataBean): SelectSendFriend4Bean {
    return SelectSendFriend4Bean().apply {
        fromeBean.let {
            id = it.id.toLong()
            showType = it.showType
            cover = it.cover
            images = it.images
            title = it.content
            content = it.content
            icon = it.icon
            name = it.name
            isFans = it.isFans
        }
    }
}

fun showShare2Bean2SelectSendFriend2Bean(fromeBean: ShowShare2Bean, lvState: Int = LIVE_STATE_NO_START): SelectSendFriend4Bean {
    var path = ""
    //动态类型  1：图片 2：视频 3话题、4文章、 5直播、6 百科  7 讲坛的视频详情
    when (fromeBean.showType) {
        //图片详情
        Constants.DYNAMIC_TYPE_IMG -> path = "${ActivityRouter.ACTIVITY.IMAGE_DETAIL}?id=${fromeBean.id}"
        //文章详情
        Constants.DYNAMIC_TYPE_ARTICLE -> path = "${ActivityRouter.COMMUNITY.ARTICLE_DETAIL}?aid=${fromeBean.id}"
        //讲坛的视频详情
        Constants.DYNAMIC_TYPE_BEMA_VIDEO_DETAIL -> path = "${ActivityRouter.COMMUNITY.COMMUNITY_PULPIT_VIDEO}?${CommunityConstant.PUL_COURSE_ID}=${fromeBean.id}&${CommunityConstant.PULPIT_ID}=${fromeBean.pulpitId}"
        //话题详情
        Constants.DYNAMIC_TYPE_TOPIC -> path = "${ActivityRouter.COMMUNITY.COMMUNITY_TOPIC_DETAIL}?tid=${fromeBean.id}"
        //直播
        Constants.DYNAMIC_TYPE_LIVE -> path = if (lvState == LIVE_STATE_NO_START) "${ActivityRouter.ACTIVITY.ACTIVE_LIVE_INFO}?id=${fromeBean.id}" else "${ActivityRouter.ACTIVITY.ACTIVE_LIVE_PLAYER}?id=${fromeBean.id}"

    }

    return SelectSendFriend4Bean().apply {
        fromeBean.let {
            id = it.id
            //动态类型  1：图片 2：视频 3话题、4文章、 5直播、6 百科  7 讲坛的视频详情
            showType = it.showType
            cover = it.cover
            images = listOf(it.cover)
            title = it.title
            content = it.content
            icon = it.headUrl
            name = it.name
            isFans = it.isFans
            route = "${if (BuildConfig.DEBUG) "thd7pq:/" else "r3fuww:/"}${path}"
            liveState = lvState
        }
    }
}








